(define "NextCanNotMove" (not (can Move (do (forEach Piece Next) ifAfterwards:(not ("IsInCheck" "King" Next))))) ) //**** Defines used to model the castling Moves. **** (define "HasNeverMoved" (= (state at:(mapEntry #1 (mover))) 1) ) (define "PieceHasMoved" (set State at:#1 0) ) (define "RememberPieceHasMoved" (then (if (= (state at:(last To)) 1) ("PieceHasMoved" (last To)) ) ) ) (define "KingNotCheckedAndToEmpty" (and (is Empty (to)) (not ("IsInCheck" "King" Mover at:(to))) ) ) (define "DecideToCastle" (move Slide (from (mapEntry #1 (mover))) #2 (between (exact #3) if:#4 ) (to if:True (apply ("PieceHasMoved" (from))) ) #5 ) ) (define "CastleRook" (slide (from (mapEntry #1 (mover))) #2 (between (exact #3) if:#4 ) (to if:True (apply ("PieceHasMoved" (from))) ) ) ) (define "SmallCastling" ("DecideToCastle" "King" E 2 "KingNotCheckedAndToEmpty" (then ("CastleRook" "RookRight" W 2 True))) ) (define "BigCastling" ("DecideToCastle" "King" W 2 "KingNotCheckedAndToEmpty" (then ("CastleRook" "RookLeft" E 3 True))) ) (define "Castling" (if (and ("HasNeverMoved" "King") (not ("IsInCheck" "King" Mover)) ) (or (if (and ("HasNeverMoved" "RookLeft") (can Move ("CastleRook" "RookLeft" E 3 (is Empty (to)))) ) "BigCastling" ) (if (and ("HasNeverMoved" "RookRight") (can Move ("CastleRook" "RookRight" W 2 (is Empty (to)))) ) "SmallCastling" ) ) ) ) //**** Defines used to model the extra Pawn moves. **** (define "SetEnPassantLocation" (then (set Pending (ahead (last To) Backward)) ) ) (define "InLocationEnPassant" (and (is Pending) (= (to) (value Pending)) ) ) (define "EnPassant" (move Step (directions {FR FL}) (to if:"InLocationEnPassant") (then (remove (ahead (last To) Backward) ) ) ) ) (define "InitialPawnMove" (if (is In (from) (sites Start (piece (what at:(from))))) ("DoubleStepForwardToEmpty" "SetEnPassantLocation") ) ) //------------------------------------------------------------------------------ (game "Beirut Chess" ("TwoPlayersNorthSouth") (equipment { (board (square 8)) ("ChessPawn" "Pawn" (or "InitialPawnMove" "EnPassant" ) (then (and ("ReplayInMovingOn" (sites Mover "Promotion")) (set Counter) ) ) ) ("ChessRook" "Rook" (then (set Counter)) ("RememberPieceHasMoved")) ("ChessKing" "King" (then (set Counter)) ("RememberPieceHasMoved")) ("ChessBishop" "Bishop" (then (set Counter))) ("ChessKnight" "Knight" (then (set Counter))) ("ChessQueen" "Queen" (then (set Counter))) (map "King" {(pair 1 "E1") (pair 2 "E8")}) (map "RookLeft" {(pair 1 "A1") (pair 2 "A8")}) (map "RookRight" {(pair 1 "H1") (pair 2 "H8")}) (regions "Promotion" P1 (sites Top)) (regions "Promotion" P2 (sites Bottom)) }) (rules (start { (place "Pawn1" (sites Row 1)) (place "Pawn2" (sites Row 6)) (place "Rook1" {"A1" "H1"} state:1) (place "Knight1" {"B1" "G1"}) (place "Bishop1" {"C1" "F1"}) (place "Queen1" coord:"D1") (place "King1" coord:"E1" state:1) (place "Rook2" {"A8" "H8"} state:1) (place "Knight2" {"B8" "G8"}) (place "Bishop2" {"C8" "F8"}) (place "Queen2" coord:"D8") (place "King2" coord:"E8" state:1) }) phases:{ (phase "Bomb" (play (forEach Site (sites Occupied by:Mover) (if (!= (what at:(site)) (id "King" Mover)) (move Select (from (site)) (then (and (set Value at:(last To) 1) (set Hidden Value at:(last To) to:Next) ) ) ) ) ) ) (nextPhase Mover "Play") ) (phase "Play" (play (if "SameTurn" (move Promote (last To) (piece {"Queen" "Knight" "Bishop" "Rook"}) Mover) (or (do (or (forEach Piece) ("Castling") ) ifAfterwards:(not ("IsInCheck" "King" Mover)) ) (move Select (from (sites Occupied by:Mover) if:(= 1 (value Piece at:(from)))) (then (forEach Site (sites Around (last To) includeSelf:True) (if (is Occupied (site)) (remove (site)) ) ) ) ) ) ) ) ) } (end { (if (or (and ("IsInCheck" "King" Next) ("NextCanNotMove") ) ("IsOffBoard" (where "King" Next)) ) (result Mover Win) ) (if ("IsOffBoard" (where "King" Mover)) (result Mover Loss)) (if (or (no Moves Mover) (= (counter) 99)) (result Mover Draw)) }) ) ) //------------------------------------------------------------------------------ (metadata (info { (description "Beirut chess is a chess variant invented by Jim Winslow in 1992. The game is played using the standard chess pieces and board, with each side having secretly equipped one of their men with a \"bomb\"—which can be \"detonated\" at any time, wiping out all men on surrounding squares along with the bomb carrier.") (rules "Beirut chess follows all the rules and conventions of standard chess, with one difference: Before the game begins, each player secretly attaches a red dot to the bottom of one of their pieces (but not the king). This piece is called a bomb carrier. On any turn, instead of moving, a player may say \"Boom!\" and overturn their bomb carrier. All pieces of either color on squares adjacent to the bomb carrier are removed from the game, as well as the bomb carrier itself. There are two ways to win: Checkmate the opponent. Blow up the enemy king. A captured piece may not be inspected to see whether or not it was a bomb carrier.") (id "1782") (source "Wikipedia") (version "1.3.12") (classification "board/war/replacement/checkmate/chess") (author "Jim Winslow") (credit "Eric Piette") (date "1992") } ) (graphics { (show Check "King") (piece Scale "Pawn" 0.825) (piece Families {"Defined" "Microsoft" "Pragmata" "Symbola"}) (board Style Chess) }) )